<?php

session_start();
include("../includes/conn.php");
$dbconn->admin_logincheck();
$adminid=$_SESSION['adminid'];
$id = isset($_GET['id'])?$_GET['id']:'';
$act = isset($_GET['act'])?$_GET['act']:'';

//if(!magic_quotes_runtime()) { 
//$_GET = daddslashes($_GET); 
//$_POST = daddslashes($_POST); 
//$_COOKIE = daddslashes($_COOKIE); 
//$_FILES = daddslashes($_FILES); 
//} 
//编辑
if($_GET['act']=='edit')
{
	$selrow=$dbconn->fetch($dbconn->query("select * from ".DBQIAN."dgpeixun where id=$id"));
	
//	$dbconn->noretquery('INSERT INTO `'.DBQIAN.'dgpeixun` (`id`, `title`, `desc`, `content`, `time`, `url`) values(null,\''.$title.'\',\''.$desc.'\',\''.$content.'\',\''.$time.'\',\''.$url.'\')');
//	$dbconn->showalert("保存成功","dgpeixun.php",1);
}
if ($act == 'add')
{
	$title=$_POST['title'];
	$desc=$_POST['desc'];
	$url=$_POST['url'];
	$content = htmlspecialchars($_POST['content1']);
	$time = date('Y-m-d H:i:s',time());
//	echo "update ".DBQIAN."dgpeixun set `title`='$title',`desc`='$desc',`content`='$content',`url`='$url' where id=".$id;exit;
	$dbconn->noretquery("update ".DBQIAN."dgpeixun set `title`='$title',`desc`='$desc',`content`='$content',`url`='$url' where id=".$id);
	$dbconn->showalert("保存成功","dgpeixun.php?act=edit&id=".$id,1);
}

;echo '<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>欢迎登录后台管理系统</title>
<link href="css/base.css" rel="stylesheet" type="text/css" />
<link href="css/right.css" rel="stylesheet" type="text/css">
<link href="css/select.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="k/themes/default/default.css" />
<link rel="stylesheet" href="k/plugins/code/prettify.css" />
<script charset="utf-8" src="k/kindeditor.js"></script>
<script charset="utf-8" src="k/lang/zh_CN.js"></script>
<script charset="utf-8" src="k/plugins/code/prettify.js"></script>
<script src="js/jquery.js"></script>
<script src="js/select-ui.min.js"></script>
<script>
$(document).ready(function(){
   $(function(){
   		$(\'#time\').datetimepicker();
   });
});
</script>
</head>
<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li><a href="index.php">首页</a></li>
    <li><a href="dgpeixun.php">导购培训</a></li>
    <li>编辑</li>
  </ul>
</div>
<div class="formbody">
  <div class="formtitle"><span>导购培训编辑</span></div>
  <form name="radd" method="post" action="?act=add&id=';echo $selrow['id'];;echo '">
  <ul class="forminfo">
    <li>
      <label>标题</label>
      <input name="title" type="text" value="';echo $selrow['title'];;echo '" class="dfinput" />
      <i></i></li>
    <li>
      <label>描述</label>
      <input name="desc" type="text" value="';echo $selrow['desc'];;echo '" class="dfinput" />
    </li>
    <li style="width:98%;height:242px;">
    	<label>规则内容</label>
    	<textarea name="content1" style="width:680px;height:240px;visibility:hidden;">';echo $selrow['content'];;echo '</textarea>
		<br />
    	<i></i>
    </li>
    <li>
      <label>跳转网址</label>
      <input name="url" type="text" value="';echo $selrow['url'];;echo '" class="dfinput" />
      <i>网址以http开头</i></li>
    <li>
      <label>&nbsp;</label>
      <input name="button" type="submit" class="btn" value="确认保存"/>
    </li>
  </ul>
  </form>
</div>
<script>
	KindEditor.ready(function(K) {
		var editor1 = K.create(\'textarea[name="content1"]\', {
			cssPath : \'k/plugins/code/prettify.css\',
			uploadJson : \'k/php/upload_json.php\',
			fileManagerJson : \'k/php/file_manager_json.php\',
			allowFileManager : true,
			afterCreate : function() {
				var self = this;
				K.ctrl(document, 13, function() {
					self.sync();
					K(\'form[name=radd]\')[0].submit();
				});
				K.ctrl(self.edit.doc, 13, function() {
					self.sync();
					K(\'form[name=radd]\')[0].submit();
				});
			}
		});
		prettyPrint();
	});
</script>
</body>
</html>'
?>